package com.example.myapplication;

import androidx.appcompat.app.AppCompatActivity;

import android.os.Bundle;
import android.util.Log;
import android.view.View;
import android.widget.Button;
import android.widget.EditText;

public class MainActivity extends AppCompatActivity {
    private EditText editTextTextPersonName;
    private EditText editTextTextPersonName2;
    private Button button;
    private Button button2;
    @Override



    protected void onCreate(Bundle savedInstanceState) {
        super.onCreate(savedInstanceState);
        setContentView(R.layout.activity_main);
        initView();


       button.setOnClickListener(new View.OnClickListener() {
            @Override
            public void onClick(View v) {
                String msg1=editTextTextPersonName.getText().toString();
                String msg2=editTextTextPersonName2.getText().toString();



             if (msg1.length()==0){
                 Log.i("登录", "用户名不能为空 ");
             }else if (msg2.length()==0){
                 Log.i("登录", "密码不能为空 ");
             }else {


                 if (msg1.equals("admin") & msg2.equals("123456")) {
                     Log.i("登录", "登陆成功 ");


                 } else {
                     Log.i("登录", "登陆失败 ");
                 }
                 editTextTextPersonName.setText(null);
                 editTextTextPersonName2.setText(null);
             }
            }
        });

     button2.setOnClickListener(new View.OnClickListener() {
         @Override
         public void onClick(View v) {
             editTextTextPersonName.setText(null);
             editTextTextPersonName2.setText(null);
         }
     });








    }



    private void initView(){
        editTextTextPersonName=(EditText)findViewById(R.id.editTextTextPersonName);
        editTextTextPersonName2=(EditText)findViewById(R.id.editTextTextPersonName2);
        button=(Button) findViewById(R.id.button);
        button2=(Button) findViewById(R.id.button2);
    }
}